package com.example.controller;


import com.example.entity.User;
import com.example.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {

    @Autowired
    private UserService userService;


    @PostMapping("list")
    public List<User> list(){
        List<User> users = userService.selectUserList();
        return users;
    }



    @PostMapping("insertUser")
    public Integer insertUser(@RequestBody User user){
        int i = userService.insertUser(user);

//        int b = 1/0;

        return i;
    }




    @PostMapping("updateUser")
    public Integer updateUser(@RequestBody User user){
        int i = userService.updateUser(user);

        return i;
    }





}
